package com.ztc.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {
	
	/**
	 * 过滤HTML里除特定标签外的所有标签
	 * 
	 * @param str
	 * @return
	 * @throws Exception
	 */
	public static String stringFilter(String str) throws Exception {
		String regEx = "(?!<(p|/p|strong|sub|sup|img).*?>)<.*?>";
		Pattern p_html = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
		Matcher m_html = p_html.matcher(str);
		str = m_html.replaceAll("");

		return str.trim(); // 返回文本字符串
	}
}
